<html>
<body>
	<script>
		function getDeviceName(){
			var ua = navigator.userAgent; 
			var device = "unknow";
			if(ua.toLowerCase().indexOf("mobile") != -1){
				if(ua.toLowerCase().indexOf("android") != -1){
					var devInfo = ua.slice(ua.indexOf("(")+1,ua.indexOf(")"));
					var devs = devInfo.split(";");
					if(devs.length > 0){
						device = devs[devs.length-1];
						if(device.toLowerCase() == " wv" && devs.length>1){//qq、微信
							device = devs[devs.length-2];
						}
					}
				}else if(ua.toLowerCase().indexOf("iphone") != -1){
					if(ua.lastIndexOf("Apple(")!=-1){
						device = ua.slice(ua.lastIndexOf("Apple(")+6,ua.lastIndexOf(")"));
					}else{
						device = "iPhone"
					}
				}else{
					device = "others";
				}
			}else{
				device = "pc"
			}
			return device;
		}
		document.write(navigator.userAgent)
		document.write("<br/>")
		document.write("<h1>device:"+getDeviceName()+"</h1>");//打印到页面  
        document.write("<br/>")
	</script>
</body>
</html>